// run: $exec < input
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

int const maxn = 200;
int da[maxn][maxn];
int n, m, sum;

void print_right()
{
	std::cout << sum << '\n';
	std::string s[2];
	s[0] = std::string(m-1, 'R');
	s[1] = std::string(m-1, 'L');
	std::cout << s[0];
	for (int i = 1; i < n; i++)
		std::cout << 'D' << s[i&1];
	std::cout << '\n';
}

void print_down()
{
	std::cout << sum << '\n';
	std::string s[2];
	s[0] = std::string(n-1, 'D');
	s[1] = std::string(n-1, 'U');
	std::cout << s[0];
	for (int i = 1; i < m; i++)
		std::cout << 'R' << s[i & 1];
	std::cout << '\n';
}

void print()
{
	std::cout << sum << '\n';
	std::string s[2];
	s[0] = std::string(m-1, 'R');
	s[1] = std::string(m-1, 'L');
	std::cout << s[0];
	for (int i = 1; i < n - 2; i++)
		std::cout << 'D' << s[i&1];
	std::cout << "DD";
	char ch[2];
	ch[0] = 'D'; ch[1] = 'U';
	for (int i = 1; i < m-2; i++)
		std::cout << 'R' << ch[i & 1];
	std::cout << 'R';
}

int const opt[4][2] = {{0, -1}, {1, 0}, {-1, 0},   {0, 1},    };
char const dir[4]   = {    'L',    'D',  'U'   ,     'R',      };
bool vis[maxn][maxn];

bool inrange(int x, int y)
{
	return (0 <= x && x < n) && (0 <= y && y < m);
}

void print_without_min(int x, int y)
{
	std::cout << x << ' ' << y << '\n';
	std::cout << sum << '\n';
	std::vector<int> v;
	v.push_back(0); v.push_back(1); v.push_back(2); v.push_back(3);
	std::string ans1;
	do {
		int px = 0, py = 0;
		std::memset(vis, 0, sizeof(vis));
		vis[px][py] = true; vis[n-1][m-1] = true; vis[x][y] = true;
		std::string ans;
		for (int i = 0; i < n * m - 2; i++) {
			if (i == n * m - 3) vis[n-1][m-1] = false;
			for (int d = 0; d < 4; d++) {
				int tx = px + opt[v[d]][0], ty = py + opt[v[d]][1];
				if (!inrange(tx, ty) || vis[tx][ty]) continue;
				ans += dir[v[d]];
				px = tx; py = ty;
				vis[tx][ty] = true;
				break;
			}
		}
		if (!(px == n-1 && py == m-1)) continue;
		std::cout << ans << '\n';
		if (ans.size() > ans1.size()) ans1 = ans;
	} while (std::next_permutation(v.begin(), v.end()));

	std::cout << ans1 << '\n';
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n >> m) {
		sum = 0;
		int px = 0, py = 0, min = 1 << 25;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++) {
				std::cin >> da[i][j];
				sum += da[i][j];
				if (da[i][j] <= min) {
					if ((i + j == 0) || (i + j == n + m - 2)) continue;
					if (!((i + j)&1)) continue;
					min = da[i][j];
					px = i;  py = j;
				}
			}

		if (n & 1) {
			print_right();
			continue;
		}
		if (m & 1) {
			print_down();
			continue;
		}

		if ((px + py) & 1) {
			sum -= min;
			print_without_min(px, py);
			continue;
		}

		sum -= std::min(da[n-2][m-1], da[n-1][m-2]);
		print();
		if (da[n-2][m-1] < da[n-1][m-2]) {
			std::cout << "DR\n";
		} else {
			std::cout << "RD\n";
		}
	}
}

